\ armasm v1.0 05.3.27 NAB
\ A postfix inline ARM assembler.
\ Based on work by Reuben Thomas.
\ Quartus Forth modifications by:
\  Steve Bohrer
\  Mark R. Browne
\  Neal Bridges

needs core-ext

module armasm

module (armasm)
  include armasm.part2
  include armasm.part3
  include armasm.part4
end-module

decimal

get-current  \ for armassembler
public:
: armassembler ( -- )
\ Like ASSEMBLER:
  get-order nip  [ swap ] literal
  swap set-order ;

: pno ( "name" -- pno-sys )
\ Begins a named ARM assembler
\ subroutine which behaves much like
\ any other Forth word.
\ The resulting word expects the
\ 16-bit dataspace address of the
\ parameters for the ARM routine,
\ and returns a double-cell result.
\ Instructions are assembled at HERE.
  falign  \ align on a 4-byte boundary
  create  also armassembler  reset
  depth cshere xor  \ security tag
  does>  -27 throw ;

: end-pno ( pno-sys -- )
\ End a pno.
  previous
  depth 1- cshere xor <>  \ security
  -22 and throw
  does> ( addr -- result. )
  >r  >abs  r> >abs PceNativeCall ;

: arm? ( -- boolean )
\ Returns TRUE if ARM CPU is present.
  0. sp@
  sysFtrNumProcessorID
  sysFileCSystem FtrGet drop
  sysFtrNumProcessorARMIfNotZero
  dand  or 0<> ;

end-module